package org.softmed.rest.editor.comps.full;

import java.awt.Color;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.JLabel;

import net.miginfocom.swing.MigLayout;

import org.softmed.rest.editor.EditorUtil;
import org.softmed.rest.editor.FilePathAware;
import org.softmed.rest.editor.FilePathProvider;
import org.softmed.rest.editor.commons.SwingUtil;
import org.softmed.rest.editor.commons.URIProvider;
import org.softmed.rest.editor.comps.ModuleEditor;
import org.softmed.rest.editor.comps.utils.DeletePanel;
import org.softmed.rest.editor.comps.utils.list.ListFieldPanel;
import org.softmed.rest.editor.comps.utils.list.showListFieldDetails;

public class ModuleEditorFull extends ModuleEditor implements getDeletePanel,
		showListFieldDetails, FilePathAware {

	DeletePanel deletePanel = new DeletePanel(this);

	ListFieldPanel list = new ListFieldPanel("Resources", "resources",
			ResourceEditorFull.class, this);

	int width = 635;

	public ModuleEditorFull(URIProvider uriProvider) throws Throwable {
		super(uriProvider);
		setup();
	}

	public void setFullBackground(Color color) {
		setBackground(color);
		list.setFullBackground(color);
		active.setBackground(color);
		deletePanel.setBackground(color);
		maxMinPanel.setBackground(color);
	}

	public void setup() {

		// setFullBackground(new Color(108, 132, 212));
		// setFullBackground(new Color(192, 211, 2));
		// setFullBackground(new Color(235, 249, 79));
		setFullBackground(new Color(243, 251, 152));

		// setBorder(BorderFactory.createLineBorder(Color.ORANGE));
		setBorder(BorderFactory.createLineBorder(new Color(249, 188, 103)));
		active.setText("Active");
		// SwingUtil.setSize(this, EditorUtil.smallestWidth,
		// EditorUtil.smallestHeight);
		SwingUtil.setMinSize(this, width, 60);
		MigLayout layout = new MigLayout("left, insets "
				+ EditorUtil.smallestInsets + ", gap 0");
		setLayout(layout);

		JLabel title = new JLabel("Module");
		title.setFont(SwingUtil.editorTitleFont);
		add(title, "w 65!");

		add(id, "w 25!");
		add(active, "w 70!");
		add(new JLabel("Name"), "w 33!");
		add(name, "w 120!");
		add(Box.createHorizontalStrut(20));
		add(new JLabel("URI"), "w 25!");
		add(relativeURI, "w 152!");
		add(deletePanel, "wrap");
		add(list, "span 10, wrap");

	}

	@Override
	public DeletePanel getDeletePanel() {
		return deletePanel;
	}

	public void setEntity(Object entity) throws Throwable {
		super.setEntity(entity);
		// list.setEntityRefresh();
	}

	@Override
	public void hideListFieldDetails() {
		list.hideListFieldDetails();

	}

	@Override
	public void showListFieldDetails() throws Throwable {
		list.showListFieldDetails();

	}

	@Override
	public void setFilePathProvider(FilePathProvider provider) {
		// resource.setFilePathProvider(provider);
		list.setFilePathProvider(provider);

	}

	@Override
	public void customMaximize() {
		// TODO Auto-generated method stub

	}

	@Override
	public void customMinimize() {
		// TODO Auto-generated method stub

	}

}
